function [cost, goodNum] = epoch(n, m,parm,p)
f = 300;
t = 20;
d = 3000;
k = 1200;

cutterX = round(wblrnd(parm(1), parm(2)));
nonCutterX = geornd(p);
X = min([cutterX, nonCutterX]);

faultNum = 0;
goodNum = 0;
checkNum = 0;

checkPoint = n;
for i = 1:m
    if i > X 
        good = 0;
        faultNum = faultNum + 1;
    else
        good = 1;
        goodNum = goodNum + 1;
    end

    
    if i == checkPoint
        checkNum = checkNum + 1;
        if good == 0
            cost = faultNum * f + checkNum * t + d;
            return
        else
            checkPoint = checkPoint + n;
        end
    end
    
    if i == m
        if good == 0
            cost = faultNum * f + checkNum * t + d;
        else
            cost = faultNum * f + checkNum * t + k;
        end
    end
    
end

end